package cn.gene.timeyan.common.utils;

import org.springframework.stereotype.Component;

/**
 * 登录账号判断正则表达式*
 *
 * @author LWG
 * @date 2022/9/5 12:33
 * @since 1.0.0 @gene.cn
 */

@Component
public class VerificationUtils {
    private static final String PHONEREGEX = "^((13[0-9])|(14[579])|(15([0-3]|[5-9]))|(16[56])|(17[0-8])|(18[0-9])|(19[1589]))\\d{8}$";
    private static final String EMAILLREGEX = "^[a-zA-Z0-9]+([-_.][A-Za-zd]+)*@([a-zA-Z0-9]+[-.])+[A-Za-zd]{2,5}$";

    public boolean isPhone(String phone){
        if (phone==null||phone.isEmpty())return false;
        if (phone.matches(PHONEREGEX)){
            return true;
        }
        return false;
    }
    public boolean isEmail(String email){
        if (email==null||email.isEmpty())return false;
        if (email.matches(EMAILLREGEX)){
            return true;
        }
        return false;
    }
}
